using System;
using System.Linq;
using System.Reflection;

namespace Duhking
{
    public class BaseMethodFinder
    {
        protected MethodInfoComparer _methodComparer = new MethodInfoComparer();

        protected bool NamesMatch(MethodInfo targetMethod, MethodInfo sourceMethod)
        {
            return targetMethod.Name == sourceMethod.Name;
        }

        protected bool ParametersMatch(MethodInfo targetMethod, MethodInfo sourceMethod)
        {
            return sourceMethod.GetParameters().Count() == targetMethod.GetParameters().Count() 
                && sourceMethod.GetParameters().Where(p => !p.ParameterType.IsGenericParameter).Select(p => p.ParameterType)
                    .Except(targetMethod.GetParameters().Where(p => !p.ParameterType.IsGenericParameter).Select(p => p.ParameterType)).Count() == 0;
        }
    }
}
